package com.globaldom.model;

import java.io.Serializable;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.globaldom.utils.MemCacheManager;

//@Configurable
@PersistenceCapable
public class CountryDetail implements Serializable {
	/**
	 * 
	 */
	@NotPersistent
	private static final long serialVersionUID = 1L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	@Persistent
	private String cName;
	@Persistent
	private String cflag;
	@Persistent
	private String cCode;

	public CountryDetail() {

	}

	public String getCName() {
		return this.cName;
	}

	public void setCName(String cName) {
		this.cName = cName;
	}

	public String getCflag() {
		return this.cflag;
	}

	public void setCflag(String cflag) {
		this.cflag = cflag;
	}

	public String getCCode() {
		return this.cCode;
	}

	public void setCCode(String cCode) {
		this.cCode = cCode;
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("Id: ").append(getId()).append(", ");
		sb.append("CName: ").append(getCName()).append(", ");
		sb.append("Cflag: ").append(getCflag()).append(", ");
		sb.append("CCode: ").append(getCCode());
		return sb.toString();
	}

	public static List<CountryDetail> findAllCountries() {
		List<CountryDetail> list;// = MemCacheManager.getAllCountries();
		// if(null!=list) return list;
//		EntityManager em = EMF.get().createEntityManager();
//		Query q = em.createQuery("select o from CountryDetail o");
//		return q.getResultList();

		return null;
	}

	public static CountryDetail findByCountryId(Integer id) {
		CountryDetail cd;// = MemCacheManager.getCountryById(id);
		// if(null!=cd) return cd;
//		EntityManager em = EMF.get().createEntityManager();
//		return em.find(CountryDetail.class, new Long(id));
return null;
	}

	public static CountryDetail findByCountryCode(String code) {
		CountryDetail cd = MemCacheManager.getCountryByCode(code);
		if (null != cd)
			return cd;
//		EntityManager em = EMF.get().createEntityManager();
//		Query queryx = em.createQuery("select o from CountryDetail o where cCode=:code");
//		queryx.setParameter("code", code);
//		cd = (CountryDetail) queryx.getSingleResult();
		return cd;

	}

}
